/**
This file is part of Gel2DE.

    Gel2DE is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Gel2DE is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Gel2DE.  If not, see <http://www.gnu.org/licenses/>.

	Copyright (C) 2012, University of Bergen
*/

#include "GelImageTransformation.h"


GelImageTransformation::GelImageTransformation(TiXmlElement* aElement)
{
	TiXmlNode *childNode;
	for(childNode = aElement->FirstChild(); childNode ; childNode = childNode->NextSibling())
	{
		TiXmlElement *el = (TiXmlElement*)childNode;
		const char* name = el->Value();
		std::string strName(name);

		if(strName == "Matrix")
		{
			double e00 = 0;
			double e01 = 0;
			double e10 = 0;
			double e11 = 0;

			el->QueryDoubleAttribute("e00", &e00);
			el->QueryDoubleAttribute("e01", &e01);
			el->QueryDoubleAttribute("e10", &e10);
			el->QueryDoubleAttribute("e11", &e11);


			m_Matrix[0][0] = e00;
			m_Matrix[0][1] = e01;
			m_Matrix[1][0] = e10;
			m_Matrix[1][1] = e11;
		}
		else if(strName == "Offset")
		{
			double offset0 = 0;
			double offset1 = 0;

			el->QueryDoubleAttribute("e0", &offset0);
			el->QueryDoubleAttribute("e1", &offset1);
			m_Offset[0] = offset0;
			m_Offset[1] = offset1;
		}
	}
}

GelImageTransformation::~GelImageTransformation(void)
{
}

GelImageTransformation::TransformType::MatrixType GelImageTransformation::getMatrix()
{
	return m_Matrix;
}

GelImageTransformation::TransformType::OffsetType GelImageTransformation::getOffset()
{
	return m_Offset;
}
